-- card: 12946 from stack: in.3 -- bmap block id: 0 -- flags: 4000 -- background id: 3241 -- name: ResList ----- HyperTalk script ----- on Install get ChooseTargetStack() InstallResource XFCN,ResList,it end Install -- part 1 (button) -- low flags: 00 -- high flags: A003 -- rect: left=299 top=300 right=322 bottom=438 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Show Pascal Source ----- HyperTalk script ----- on mouseUp set the visible of card field 1 to not the visible of card field 1 if the visible of card field 1 is true then set the name of me to "Hide Pascal Source" else set the name of me to "Show Pascal Source" end mouseUp -- part 2 (field) -- low flags: 81 -- high flags: 2007 -- rect: left=12 top=26 right=298 bottom=491 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 22 -- text size: 10 -- style flags: 0 -- line height: 13 -- part name: Source -- part contents for background part 16 ----- text ----- RESLIST XFCN version 1.0.1 Kevin Calhoun ResList returns information about the resources contained in a file. It returns one line of information for each resource contained in the target file. Each line contains four items separated by commas. Item 1 will be the resource type, item 2 the resource name, item 3 the resource ID, and item 4 the size of the resource in bytes. What follows is excerpted from the information ResList returns when the target file is the famous ResCopy XCMD stack: XCMD,ResCopy,10000,23002 CURS,Mouse!,1000,68 XFCN,NewFileName,914,1334 XFCN,FileName,913,2040 INVOKING RESLIST get ResList(<"targetFile">) The targetFile parameter is optional. If it is not included, ResList returns information about the current stack. If it is included and represents the full pathname of an existing resource file, ResList returns information about that file. Revision history: 15 March 1989 -- first release. 11 June 1989 -- Now returns empty when file has no resource fork. -- part contents for card part 2 ----- text ----- UNIT ResListUnit; { ResList XFCN ©1989 by the Trustees of Dartmouth College } { Written by Kevin Calhoun } { This source compatible with MPW Pascal 3.0 } (* Pascal ResList.p Link -m ENTRYPOINT ∂ -o "YourFile" ∂ -rt XFCN=7509 ∂ -sn Main=ResList ∂ ResList.p.o ∂ "{Libraries}"interface.o ∂ "{PLibraries}"Paslib.o ∂ "{Libraries}"HyperXLib.o *) {$S ResList } {$R-} interface USES Types, Memory, Resources, Files, ToolUtils, OSUtils, SysEqu, Errors, HyperXCmd; PROCEDURE EntryPoint (paramPtr : XCMDPtr); IMPLEMENTATION {-----------------------------------------------------------------} PROCEDURE ResList (paramPtr: XCMDPtr); FORWARD; PROCEDURE EntryPoint (paramPtr : XCMDPtr); BEGIN ResList(paramPtr); END; FUNCTION AppendString (h: Handle; str: Str255): OSErr; BEGIN AppendString := PtrAndHand(POINTER(ORD4(@str)+1), h, LENGTH(str)); END; FUNCTION MyOpenResFile(fileName: Str255; VAR refNum: INTEGER; VAR wasOpen: BOOLEAN): OSErr; TYPE HandlePtr = ^Handle; VAR oldTopMapHndl: Handle; BEGIN MyOpenResFile := noErr; oldTopMapHndl := HandlePtr(TopMapHndl)^; { remember current TopMapHndl } refNum := OpenResFile(fileName); { open resource file } IF (refNum = -1) THEN { error opening file } BEGIN MyOpenResFile := ResError; EXIT(MyOpenResFile); END ELSE IF (oldTopMapHndl = HandlePtr(TopMapHndl)^) THEN wasOpen := TRUE { no change -- it was open } ELSE wasOpen := FALSE; { res file wasn't open before } END; FUNCTION GetTheNameOfThisStack (paramPtr : XCMDPtr; var str: Str255): OSErr; VAR theResult : Handle; theLength : Longint; err: OSErr; BEGIN err := noErr; str := 'word 2 of the long name of this stack'; theResult := EvalExpr(paramPtr, str); err := paramPtr^.result; IF (theResult <> NIL) and (err = noErr) THEN BEGIN theLength := StringLength(paramPtr, theResult^); ZeroToPas(paramPtr, theResult^, str); DisposHandle(theResult); DELETE(str,theLength,1); DELETE(str,1,1); END ELSE str := ''; GetTheNameOfThisStack := err; END; PROCEDURE ResList (paramPtr: XCMDPtr); LABEL 98, 99, 100; TYPE Str1 = String[1]; VAR paramCount : INTEGER; fileName : Str255; theRefNum : INTEGER; saveResFile: INTEGER; numTypes, numResources: INTEGER; theType: ResType; i, j: INTEGER; theResource: Handle; theID: INTEGER; name, typeStr, IDStr, sizeStr: Str255; resourceList: Handle; comma, zero, return: Str1; alreadyOpen: BOOLEAN; nullPos: INTEGER; err: OSErr; curs: CursHandle; zeroPtr: Ptr; PROCEDURE PassReturnValue (errMsg : Str255); { set theResult } BEGIN paramPtr^.returnValue := PasToZero(paramPtr, errMsg); END; BEGIN err := noErr; paramCount := paramPtr^.paramCount; IF paramCount > 1 THEN BEGIN PassReturnValue('ResList XFCN 1.0.1, 11 June 1989, ©1989 Dartmouth College'); GOTO 100; END; curs := GetCursor(watchCursor); SetCursor(curs^^); saveResFile := CurResFile; { save the current resource file } IF paramCount > 0 THEN ZeroToPas(paramPtr, paramPtr^.params[1]^, fileName) ELSE BEGIN err := GetTheNameOfThisStack(paramPtr,fileName); IF err <> noErr THEN GOTO 99; END; err := MyOpenResFile(fileName, theRefNum, alreadyOpen); IF err <> noErr THEN GOTO 99; SetResLoad(FALSE); UseResFile(theRefNum); numTypes := Count1Types; IF numTypes = 0 THEN GOTO 98; resourceList := NewHandle(0); err := MemError; IF err <> noErr then GOTO 98; comma := ','; zero := comma; zero[1] := CHR(0); return := comma; return[1] := CHR($0D); typeStr[0] := CHR(4); FOR i := 1 to numTypes DO BEGIN Get1IndType(theType, i); numResources := Count1Resources(theType); FOR j := 1 to numResources DO BEGIN theResource := Get1IndResource(theType, j); GetResInfo(theResource, theID, theType, name); { remove nulls from resource name } nullPos := POS(zero, name); WHILE nullPos > 0 DO BEGIN DELETE(name, nullPos, 1); nullPos := POS(zero, name); END; NumToStr(paramPtr, theID, IDStr); NumToStr(paramPtr, SizeResource(theResource), sizeStr); BlockMove(@theType, POINTER(ORD4(@typeStr)+1), 4); err := AppendString(resourceList, CONCAT(typeStr, ',', name, ',', IDStr, ',', sizeStr, return)); IF err <> noErr THEN BEGIN DisposHandle(resourceList); GOTO 98; END; END; END; HLock(resourceList); zeroPtr := POINTER(ORD4(resourceList^)+GetHandleSize(resourceList)-1); zeroPtr^ := 0; HUnlock(resourceList); paramPtr^.returnValue := resourceList; 98: IF NOT alreadyOpen THEN CloseResFile(theRefNum); SetResLoad(TRUE); UseResFile(saveResFile); 99: InitCursor; 100: IF (err <> noErr) AND (err <> eofErr) THEN BEGIN NumToStr(paramPtr, err, name); PassReturnValue(CONCAT('Error ', name)); END; END; END.